<style>.footer.footer-home {display: none;}
    #my-order-page{margin-top: 0;}
</style>
<div id="my-order-page">
<div class="header">
    <a href="index.php?act=member" class="return iconfont icon-shangyiye"></a>
    <div class="header-title">订单管理</div>
</div>
<div class="order-select">
    <ul>
        <li>
            <a href="index.php?act=merchant&op=order" class="<?php echo $output['state'] == 0?'green':''; ?>">
                <i class="iconfont icon-jilu"></i>
                <p>全部</p>
            </a>
        </li>
        <li>
            <a href="index.php?act=merchant&op=order&state=1" class="<?php echo $output['state'] == 1?'green':''; ?>">
                <i class="iconfont icon-qianbao"></i>
                <p>待支付</p>
            </a>
        </li>
        <li>
            <a href="index.php?act=merchant&op=order&state=2" class="<?php echo $output['state'] == 2?'green':''; ?>">
                <i class="iconfont icon-youhuiquan"></i>
                <p>待使用</p>
            </a>
        </li>
        <li>
            <a href="index.php?act=merchant&op=order&state=3" class="<?php echo $output['state'] == 3?'green':''; ?>">
                <i class="iconfont icon-yiwancheng"></i>
                <p>已完成</p>
            </a>
        </li>
        <li>
            <a href="index.php?act=merchant&op=order&state=4" class="<?php echo $output['state'] == 4?'green':''; ?>">
                <i class="iconfont icon-yiquxiao"></i>
                <p>已取消</p>
            </a>
        </li>
    </ul>
</div>

<div class="order-list" style="margin-bottom: 5rem;">
    <ul>
        <?php if (!empty($output['orders'])): ?>
        <?php foreach ($output['orders'] as $order): ?>
        <li style="margin-bottom: 1rem;">
            <div class="list-top line">
                <span class="left"><?php echo $output['order_type'][$order['order_type']]?><?php //echo $order['order_sn']; ?></span>
                <span class="right green fr"><?php echo $output['status'][$order['order_status']]; ?></span>
            </div>
            <?php if($order['order_type']==2){ ?>
            <?php foreach ($order['sku'] as $sku): ?>
            <a href="index.php?act=merchant&op=orderdetail&ordersn=<?php echo $order['order_sn']; ?>">
            <div class="list-mid">
                <div class="list-img">
                    <img src="<?php echo $order['ticket_thumb']; ?>" />
                </div>
                <div class="list-info">
                    <p class="title"><?php echo $order['ticket_title']; ?></p>
                    <div><span>¥</span><?php echo $sku['ot_price']; ?><span> / 张</span> <span class="fr">×<?php echo $sku['ot_num']; ?></span></div>
                    <p class="code">取票码:<?php echo $order['ticket_code'] ? substr($order['ticket_code'],0,10).str_repeat('x',6) : ''; ?></p>
                </div>
            </div>
            </a>
            <?php endforeach; ?>
            <?php }elseif($order['order_type']==1){ ?>
                <?php foreach ($order['sku'] as $sku): ?>
                <a href="index.php?act=merchant&op=orderdetail&ordersn=<?php echo $order['order_sn']; ?>">
                    <div class="list-mid">
                        <div class="list-img">
                            <img src="<?php echo $order['ticket_thumb']; ?>" />
                        </div>
                        <div class="list-info">
                            <p class="title"><?php echo $order['ticket_title']; ?></p>
                            <p class="title"><?php echo $order['spec_name']; ?></p>
                            <div><span>¥</span><?php echo $sku['unit_price']; ?><span> / 间</span> <span class="fr">×<?php echo $sku['oh_num']; ?></span></div>
                            <p class="code">核销码:<?php echo $order['ticket_code'] ? substr($order['ticket_code'],0,10).str_repeat('x',6) : ''; ?></p>
                        </div>
                    </div>
                </a>
                <?php endforeach; ?>
            <?php }else {?>
                <!-- 美食 -->
                <?php foreach ($order['sku'] as $sku): ?>
                    <a href="index.php?act=member&op=orderdetail&ordersn=<?php echo $order['order_sn']; ?>">
                        <div class="list-mid">
                            <div class="list-img">
                                <img src="<?php echo $order['ticket_thumb']; ?>" />
                            </div>
                            <div class="list-info">
                                <p class="title"><?php echo $order['ticket_title'] ?></p>
                                <div><span>¥</span><?php echo $sku['og_price']; ?><span> / 份</span> <span class="fr">×<?php echo $sku['og_num']; ?></span></div>
                                <p class="code">核销码:<?php echo $order['ticket_code'] ? substr($order['ticket_code'],0,10).str_repeat('x',6) : ''; ; ?></p>
                            </div>
                        </div>
                    </a>
                <?php endforeach; ?>
            <?php } ?>
            <div class="list-bot line">
                <samp>合计：</samp><span>¥<?php echo $order['need_pay']; ?></span>
            </div>
        </li>
        <?php endforeach; ?>
        <?php else: ?>
            <div class="empty">暂无内容</div>
        <?php endif; ?>
    </ul>
    <div class="load hide">正在加载...</div>
</div>
</div>

<script>
    var allNum = <?php echo $output['TotalNum']; ?>,
        allPage = <?php echo $output['TotalPage']; ?>,
        curPage = 1;

    var is_scroll = false;
    //ajax加载数据
    function loadpage() {
        if(!is_scroll){
            return;
        }
        if (curPage < allPage) {
            curPage += 1;
        } else {
            $('.load').text('没有更多内容了').show();
            return;
        }
        $.get(location.href, {isajax:1,curpage:curPage},function(data){
            if(data){
                $(".order-list > ul").append(data);
                $('.load').hide();
            }
        });
    }
    $(window).scroll(function () {
        $('.load').show();
        is_scroll = true;
        //已经滚动到上面的页面高度
        var scrollTop = $(this).scrollTop();
        //页面高度
        var scrollHeight = $(document).height();
        //浏览器窗口高度
        var windowHeight = $(this).height();
        //此处是滚动条到底部时候触发的事件，在这里写要加载的数据，或者是拉动滚动条的操作
        if (scrollTop + windowHeight == scrollHeight) {
            loadpage();
        }
    });
</script>